package com.baichang.taoshunda.dao.impl;

import com.baichang.framework.dao.impl.BaseDaoImpl;
import com.baichang.taoshunda.dao.CompanyBalanceDao;
import com.baichang.taoshunda.entity.CompanyBalance;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class CompanyBalanceDaoImpl extends BaseDaoImpl<CompanyBalance> implements CompanyBalanceDao {

    /**
     * 根据日期查看商家账单
     *
     * @param bussId    商家编号
     * @param startDate
     * @param date      日期  @return
     * @param nowPage
     * @param pageSize
     */
    @Override
    public List<Map<String, Object>> findBussinessBills(Integer bussId, String startDate, String date, Integer nowPage, Integer pageSize) {
        String sql = "SELECT cb.*, o.order_type AS orderType FROM t_company_balance cb INNER JOIN t_order o ON o.order_number = cb.order_number WHERE buss_id = ? AND TO_DAYS(cb.created) >= TO_DAYS(?) AND TO_DAYS(cb.created) <= TO_DAYS(?) AND source_type != 3 ORDER BY cb.created DESC";
        return listForMapList(sql, nowPage, pageSize, bussId, startDate, date);
    }


}
